<?php
declare (strict_types=1);

namespace app\admin\controller;

use app\common\facade\Builder;

class Reservation extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Reservation';

    //关联模型
    protected array $hasOne = ['p', 'c', 'd', 't'];

    public function index(): string
    {
        //构建表格数据
        return Builder::Table()
            ->addColumn(['type' => 'checkbox', 'title' => '全选', 'fixed' => 'left'])
            ->addColumn(['field' => 'id', 'sort' => true, 'title' => 'ID', 'width' => 80])
            ->addColumn(['field' => 'name', 'title' => '姓名', 'modify' => '2,input'])
            ->addColumn(['field' => 'mobile', 'title' => '手机号', 'modify' => '2,input'])
            ->addColumn(['field' => '', 'title' => '地址', 'templet' => '<div>{{d.p.title}}-{{d.c.title}}-{{d.d?d.d.title:""}}-{{d.t?d.t.title:""}}</div>', 'width' => 150])
            ->addColumn(['field' => 'details', 'title' => '详细地址', 'modify' => '2,input'])
            ->addColumn(['field' => 'maintain', 'title' => '维修类型', 'modify' => '2,input'])
            ->addColumn(['field' => 'images', 'title' => '缩略图', 'modify' => '2,img,1', 'templet' => '#imagesTpl'])
            ->addColumn(['field' => 'content', 'title' => '客户要求', 'modify' => '2,rich_text', 'templet' => '#editorTpl'])
            ->addColumn(['field' => 'desire_time', 'title' => '期望时间'])
            ->addColumn(['field' => 'create_time', 'title' => '留言时间'])
//            ->addColumn(['fixed' => 'right', 'title' => '操作', 'align' => 'center', 'toolbar' => '#barDemo', 'width' => 200])
//            ->addRightButtons(['edit' => ['size' => '1000,1000'], 'delete'])
//            ->addTopButtons(['add' => ['size' => '1000,1000'], 'deleteAll'])
            ->addSearch([
                ['name', '姓名搜索', 'input,Like'],
            ])
            ->fetch();
    }


}
